package com.example.reactor.r2dbc.db.jdbc;

import com.zaxxer.hikari.HikariDataSource;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

import javax.sql.DataSource;

/**
 * @author zpMeng
 * @since 6/16/2025
 */
@Configuration
public class DatabaseConfig {

    // ========== JDBC 配置 ==========
    @Bean
    @Primary
    @ConfigurationProperties("spring.datasource")
    public DataSource jdbcDataSource() {
        return DataSourceBuilder
                .create()
                .type(HikariDataSource.class)
                .build();
    }

}
